package com.fhp;

import java.util.Scanner;

public class test {
    private static final int INIT_STATE = 0;
    private static final int LOGIN_STATE = 1;
    private static final int PROFILE_STATE = 2;
    private static final int LOGOUT_STATE = 3;

    public static void main(String[] args) {
        int currentState = INIT_STATE;
        boolean exit = false;
        Scanner scanner = new Scanner(System.in);
        while (!exit) {
            switch (currentState) {
                case INIT_STATE:
                    System.out.println("Welcome to the system!");
                    System.out.println("1. Log in");
                    System.out.println("2. Exit");
                    int initOption = scanner.nextInt();
                    if (initOption == 1) {
                        currentState = LOGIN_STATE;
                    } else if (initOption == 2) {
                        exit = true;
                    } else {
                        System.out.println("Invalid option!");
                    }
                    break;
                case LOGIN_STATE:
                    System.out.println("Logged in successfully!");
                    System.out.println("1. View profile");
                    System.out.println("2. Log out");
                    int loginOption = scanner.nextInt();
                    if (loginOption == 1) {
                        currentState = PROFILE_STATE;
                    } else if (loginOption == 2) {
                        currentState = LOGOUT_STATE;
                    } else {
                        System.out.println("Invalid option!");
                    }
                    break;
                case PROFILE_STATE:
                    System.out.println("Viewing profile...");
                    currentState = LOGIN_STATE;
                    break;
                case LOGOUT_STATE:
                    System.out.println("Logged out successfully!");
                    currentState = INIT_STATE;
                    break;
                default:
                    System.out.println("Invalid state!");
                    exit = true;
                    break;
            }
        }
    }

}
